<template>
  <transition name="fade">
    <div class="header-detail" @touchmove.stop.prevent @click="hideFn" v-if="seller">
      <div class="detail-wrapper clear-fix">
        <div class="detail-main">
          <h1 class="name">{{seller.name}}</h1>
          <div class="star-wrapper">
            <cube-rate v-model="score"></cube-rate>
          </div>
          <div class="title">
            <div class="line"></div>
            <div class="text">优惠信息</div>
            <div class="line"></div>
          </div>
          <ul v-if="seller.supports" class="supports">
            <li class="support-item" v-for="(item,index) in seller.supports" :key="item.id">
              <!-- {{imgUrl[index]}} -->
              <span class="support-ico" :class="'icon'+index">
                <!--<img :src="imgUrl[index]" alt />-->
                <img :src="require('../assets/imgs/icon'+index+'.png')" alt />
              </span>
              <span class="text">{{seller.supports[index].description}}</span>
            </li>
          </ul>
          <div class="title">
            <div class="line"></div>
            <div class="text">商家公告</div>
            <div class="line"></div>
          </div>
          <div class="bulletin">
            <p class="content">{{seller.bulletin}}</p>
          </div>
        </div>
      </div>
      <div class="detail-close">
        <i class="cubeic-close"></i>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: "header-detail",
  props: {
    seller: Object
  },
  data() {
    return {
      score: 0,
      isMask: true,
      imgUrl: [
        require("../assets/imgs/icon0.png"),
        require("../assets/imgs/icon1.png"),
        require("../assets/imgs/icon2.png"),
        require("../assets/imgs/icon3.png"),
        require("../assets/imgs/icon4.png")
      ]
    };
  },
  watch: {
    seller(newVal) {
      this.seller = newVal;
      this.score = newVal.score;
    }
  },
  methods: {
    hideFn() {
      this.isMask = false;
      this.$emit("hideMask", this.isMask);
    }
  }
};
</script>

<style lang="stylus" scoped>
.header-detail {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  backdrop-filter: blur(10px);
  opacity: 1;
  color: #fff;
  background: rgba(7, 17, 27, 0.8);

  &.fade-enter-active, &.fade-leave-active {
    transition: all 0.5s;
  }

  &.fade-enter, &.fade-leave-active {
    opacity: 0;
    background: $color-background;
  }

  .detail-wrapper {
    display: inline-block;
    width: 100%;
    min-height: 100%;

    .detail-main {
      margin-top: 64px;
      padding-bottom: 64px;

      .name {
        line-height: 16px;
        text-align: center;
        font-size: 16px;
        font-weight: 700;
      }

      .star-wrapper {
        margin-top: 18px;
        padding: 2px 0;
        text-align: center;
      }

      .title {
        display: flex;
        width: 80%;
        margin: 28px auto 24px auto;

        .line {
          flex: 1;
          position: relative;
          top: -6px;
          border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }

        .text {
          padding: 0 12px;
          font-weight: 700;
          font-size: 14px;
        }
      }

      .supports {
        width: 80%;
        margin: 0 auto;

        .support-item {
          display: flex;
          align-items: center;
          padding: 0 12px;
          margin-bottom: 12px;

          &:last-child {
            margin-bottom: 0;
          }

          .support-ico {
            margin-right: 6px;
            height: 16px;
            width: 16px;

            img {
              width: 100%;
            }
          }

          .text {
            line-height: 16px;
            font-size: 12px;
          }
        }
      }

      .bulletin {
        width: 80%;
        margin: 0 auto;

        .content {
          padding: 0 12px;
          line-height: 24px;
          font-size: 12px;
          text-align: left;
        }
      }
    }
  }

  .detail-close {
    position: fixed;
    width: 30px;
    height: 30px;
    bottom: 50px;
    left: 50%;
    transform: translateX('-50%');

    .cubeic-close {
      font-size: 30px;
    }
  }
}

>>>.cube-rate-item {
  width: 20px;
  margin-right: 20px;
}
</style>
